package com.deer.wms.base.system.service.plan.impl;

import com.deer.wms.base.system.dao.plan.SchedulePlanMapper;
import com.deer.wms.base.system.model.plan.SchedulePlan;
import com.deer.wms.base.system.model.plan.SchedulePlanCriteria;
import com.deer.wms.base.system.model.plan.SchedulePlanExample;
import com.deer.wms.base.system.service.plan.IPlanSetService;
import com.deer.wms.common.core.service.AbstractService;
import com.deer.wms.common.core.text.Convert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PlanSetServiceImpl extends AbstractService<SchedulePlan,Integer> implements IPlanSetService {

    @Autowired
    SchedulePlanMapper schedulePlanMapper;

    @Override
    public List<SchedulePlan> selectPlanList(SchedulePlanCriteria p) {

        SchedulePlanExample example = new SchedulePlanExample();
        SchedulePlanExample.Criteria criteria = example.createCriteria();

        if(p!=null && p.getPlanName()!=null)
        {
            example.setDistinct(false);
            criteria.andPlannameLike(p.getPlanName());
        }
        return schedulePlanMapper.selectPlanList(new SchedulePlan());
    }


    @Override
    public SchedulePlan findByPid(Integer PId) {
        return schedulePlanMapper.findByPid(PId);
    }

    @Override
    public List<SchedulePlan> findList(SchedulePlan schedulePlan) {
        return schedulePlanMapper.findList(schedulePlan);
    }

    @Override
    public int delectBarCodeByPid(Integer PId) {

        return schedulePlanMapper.delectBarCodeByPid(PId);
    }

    @Override
    public int delectBarCodeByPids(String PIds ) {
        return schedulePlanMapper.delectBarCodeByPids(Convert.toStrArray(PIds));
    }

    @Override
    public int updateSchedulePlan(SchedulePlan schedulePlan) {
        return schedulePlanMapper.updateSchedulePlan(schedulePlan);
    }

    @Override
    public int saveSchedulePlan(SchedulePlan schedulePlan) {
        return schedulePlanMapper.saveSchedulePlan(schedulePlan);
    }


}
